//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.hbase.controller;

import com.hbase.utils.DataSourceContextHolder;
import com.hbase.utils.DataSourceType;
import com.sitech.common.utils.StringUtils;
import com.ssm.pojo.User;
import com.ssm.service.UserService;
import com.yhzhou.test.Test1;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.log4j.Logger;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import redis.clients.jedis.Jedis;

import static com.hbase.ApplicationConfig.*;
import static com.hbase.ApplicationConfig.DATABASE1;
import static com.hbase.utils.RandomUtil.testMathRandom1000;
import static com.hbase.utils.RandomUtil.testMathRandom10000;
import static com.hbase.utils.RandomUtil.testUrl;
import static java.lang.Thread.sleep;

@Controller
@RequestMapping({"/activity"})
public class TestController {
    private static final Map<Integer, String> networkTypeMap = new HashMap();
    private static final Map<Integer, String> systemMap = new HashMap();
    @Autowired
    private UserService userService;
    protected static final Logger logger = Logger.getLogger(TestController.class);

    public TestController() {
    }

    @RequestMapping({"/testSave.do"})
    public String toIndex1(HttpServletRequest request, Model model) {
        return "User";
    }

    @RequestMapping({"/testQuery.do"})
    public String testQuery(HttpServletRequest request, Model model) throws Exception {

        new Test1();
        User user=this.userService.getUserById("admin");
        Jedis jedis = new Jedis("172.18.193.43",32768);
        jedis.set("foo", "bar");
        String value = jedis.get("foo");
//        RedisDataSource.getClient().set("name", "陈浩翔");
        System.out.println(value);
        logger.info("/testQuery.do");
        int i=testMathRandom1000();

        if(i%SLEEP_RATE==0){
            sleep(i*10);
        }

        i=testMathRandom1000();
        if(i% ERROR_RATE ==0){
            throw new NullPointerException();
        }
        return "User";
    }

    @RequestMapping({"/turntable.do"})
    public String turntable(HttpServletRequest request, Model model) throws Exception {

        new Test1();
        User user=this.userService.getUserById("admin");
        Jedis jedis = new Jedis("172.18.193.43",32768);
        jedis.set("foo", "bar");
        String value = jedis.get("foo");
//        RedisDataSource.getClient().set("name", "陈浩翔");
        System.out.println(value);
        logger.info("/testQuery.do");
        int i=testMathRandom1000();

        if(i%SLEEP_RATE==0){
            sleep(i*10);
        }

        i=testMathRandom1000();
        if(i% ERROR_RATE ==0){
            throw new NullPointerException();
        }
        return "User";
    }

    @RequestMapping({"/fatherDay.do"})
    public String fatherDay(HttpServletRequest request, Model model) throws Exception {

        new Test1();
        User user=this.userService.getUserById("admin");
        Jedis jedis = new Jedis("172.18.193.43",32768);
        jedis.set("foo", "bar");
        String value = jedis.get("foo");
//        RedisDataSource.getClient().set("name", "陈浩翔");
        System.out.println(value);
        logger.info("/testQuery.do");
        int i=testMathRandom1000();

        if(i%SLEEP_RATE==0){
            sleep(i*10);
        }

        i=testMathRandom1000();
        if(i% ERROR_RATE ==0){
            throw new NullPointerException();
        }
        return "User";
    }

    @RequestMapping({"/midAutomActivity.do"})
    public String midAutomActivity(HttpServletRequest request, Model model) throws Exception {

        new Test1();
        User user=this.userService.getUserById("admin");
        Jedis jedis = new Jedis("172.18.193.43",32768);
        jedis.set("foo", "bar");
        String value = jedis.get("foo");
//        RedisDataSource.getClient().set("name", "陈浩翔");
        System.out.println(value);
        logger.info("/testQuery.do");
        int i=testMathRandom1000();

        if(i%SLEEP_RATE==0){
            sleep(i*10);
        }

        i=testMathRandom1000();
        if(i% ERROR_RATE ==0){
            throw new NullPointerException();
        }
        return "User";
    }

    @RequestMapping({"/report.do"})
    public String report(HttpServletRequest request, Model model) throws Exception {

        new Test1();
//        userService.selectSlowSql("123456789");
        return "User";
    }

    @RequestMapping({"/scratchCard.do"})
    public String scratchCard(HttpServletRequest request, Model model) throws Exception {

        new Test1();
        User user=this.userService.getUserById("admin");
        Jedis jedis = new Jedis("172.18.193.43",32768);
        jedis.set("foo", "bar");
        String value = jedis.get("foo");
//        RedisDataSource.getClient().set("name", "陈浩翔");
        System.out.println(value);
        logger.info("/testQuery.do");
        int i=testMathRandom1000();

        if(i%SLEEP_RATE==0){
            sleep(i*10);
        }

        i=testMathRandom1000();
        if(i% ERROR_RATE ==0){
            throw new NullPointerException();
        }
        return "User";
    }

    public static void executeGet(String url) {
        HttpClient client = new DefaultHttpClient();
        HttpGet get = new HttpGet(url);

        try {
            HttpResponse res = client.execute(get);
            if (res.getStatusLine().getStatusCode() != 200) {
                ;
            }
        } catch (Exception var7) {
            throw new RuntimeException(var7);
        } finally {
            client.getConnectionManager().shutdown();
        }

    }

    private static int fab(int index) {
        return index != 1 && index != 2 ? fab(index - 1) + fab(index - 2) : 1;
    }

    @RequestMapping({"/certificationCenter.do"})
    public String certificationCenter(HttpServletRequest request,
                                      HttpServletResponse response,
                                      Model model) throws Exception {
        new Test1();
        logger.info("fdfdfdfdfdfdfs");
        logger.info(MDC.get("PtxId"));
        String url=request.getParameter("url");
        logger.info(url);
        executeGet(url);
        this.userService.getUserById("admin");
        int i=testMathRandom1000();
//        this.userService.selectSlowSql("admin");
        if(i% CERT_RATE ==0){
            throw new NullPointerException();
        }
        return "User";
    }



    @RequestMapping({"/testSave1.do"})
    public String testQuery1(HttpServletRequest request,
                             HttpServletResponse response,
                             Model model) throws Exception {
        new Test1();
        logger.info("fdfdfdfdfdfdfs");
        logger.info(MDC.get("PtxId"));
        String url=request.getParameter("url");
        logger.info(url);
        executeGet(url);
        this.userService.getUserById("admin");
        int i=testMathRandom1000();
        if(i% CERT_RATE ==0){
            throw new NullPointerException();
        }
        return "User";
    }

    static {
        int i = 0;
//        int i = i + 1;
        networkTypeMap.put(i, "WIFI");
        ++i;
        networkTypeMap.put(i, "4G");
        ++i;
        networkTypeMap.put(i, "3G");
        ++i;
        networkTypeMap.put(i, "2G");
        ++i;
        networkTypeMap.put(i, "LTE");
        ++i;
        networkTypeMap.put(i, "CDMA");
        ++i;
        networkTypeMap.put(i, "CDMA2000");
        i = 0;
        i = i + 1;
        systemMap.put(i, "ANDROID");
        ++i;
        systemMap.put(i, "IOS");
        ++i;
        systemMap.put(i, "MIUI");
        ++i;
        systemMap.put(i, "YUMOS");
    }

    @RequestMapping({"/coreAdd.do"})
    public String coreAdd(HttpServletRequest request, Model model) throws Exception {

        int i=testMathRandom10000();

        new Test1();
        Integer rootApp=Integer.parseInt(ROOT_APP);
        Integer database1=Integer.parseInt(DATABASE1);
        Integer database2=0;
        if(!StringUtils.isEmptyOrNull(DATABASE2)){
            database2=Integer.parseInt(DATABASE2);
        }

        int max=rootApp;
        int min=database1+database2;
        if(max<min){

            //访问应用小于数据库
            max=min;
            min=rootApp;

            if(i%min<(max/2)){
                User user=this.userService.getUserById("admin");
                User user1=this.userService.getUserById("admin");
            }
        }else{

//            访问数据库小于访问应用
            if(i%max<min){
                User user=this.userService.getUserById("admin");
            }

        }

        i=testMathRandom1000();

        if(i%SLEEP_RATE==0){
            sleep(i*10);
        }

        if(i% ERROR_RATE ==0){
            throw new NullPointerException();
        }
        return "User";
    }

    @RequestMapping({"/coreQuery.do"})
    public String coreQuery(HttpServletRequest request, Model model) throws Exception {

        int i=testMathRandom10000();

        new Test1();
        Integer rootApp=Integer.parseInt(ROOT_APP);
        Integer database1=Integer.parseInt(DATABASE1);
        Integer database2=0;
        if(!StringUtils.isEmptyOrNull(DATABASE2)){
            database2=Integer.parseInt(DATABASE2);
        }

        int max=rootApp;
        int min=database1+database2;
        if(max<min){

            //访问应用小于数据库
            max=min;
            min=rootApp;

            if(i%min<(max/2)){
                User user=this.userService.getUserById("admin");
                User user1=this.userService.getUserById("admin");
            }
        }else{

//            访问数据库小于访问应用
            if(i%max<min){
                User user=this.userService.getUserById("admin");
            }

        }

        i=testMathRandom1000();

        if(i%SLEEP_RATE==0){
            sleep(i*10);
        }

        if(i% ERROR_RATE ==0){
            throw new NullPointerException();
        }
        return "User";
    }

    @RequestMapping({"/coreDelete.do"})
    public String coreDelete(HttpServletRequest request, Model model) throws Exception {

        int i=testMathRandom10000();

        new Test1();
        Integer rootApp=Integer.parseInt(ROOT_APP);
        Integer database1=Integer.parseInt(DATABASE1);
        Integer database2=0;
        if(!StringUtils.isEmptyOrNull(DATABASE2)){
            database2=Integer.parseInt(DATABASE2);
        }

        int max=rootApp;
        int min=database1+database2;
        if(max<min){

            //访问应用小于数据库
            max=min;
            min=rootApp;

            if(i%min<(max/2)){
                User user=this.userService.getUserById("admin");
                User user1=this.userService.getUserById("admin");
            }
        }else{

//            访问数据库小于访问应用
            if(i%max<min){
                User user=this.userService.getUserById("admin");
            }

        }

        i=testMathRandom1000();

        if(i%SLEEP_RATE==0){
            sleep(i*10);
        }

        if(i% ERROR_RATE ==0){
            throw new NullPointerException();
        }
        return "User";
    }

    @RequestMapping({"/coreUpdate.do"})
    public String coreUpdate(HttpServletRequest request, Model model) throws Exception {

        int i=testMathRandom10000();

        new Test1();
        Integer rootApp=Integer.parseInt(ROOT_APP);
        Integer database1=Integer.parseInt(DATABASE1);
        Integer database2=0;
        if(!StringUtils.isEmptyOrNull(DATABASE2)){
            database2=Integer.parseInt(DATABASE2);
        }

        int max=rootApp;
        int min=database1+database2;
        if(max<min){

            //访问应用小于数据库
            max=min;
            min=rootApp;

            if(i%min<(max/2)){
                User user=this.userService.getUserById("admin");
                User user1=this.userService.getUserById("admin");
            }
        }else{

//            访问数据库小于访问应用
            if(i%max<min){
                User user=this.userService.getUserById("admin");
            }

        }

        i=testMathRandom1000();

        if(i%SLEEP_RATE==0){
            sleep(i*10);
        }

        if(i% ERROR_RATE ==0){
            throw new NullPointerException();
        }
        return "User";
    }

    @RequestMapping({"/core.do"})
    public String core(HttpServletRequest request, Model model) throws Exception {

        int i=testMathRandom10000();

        new Test1();
        Integer rootApp=Integer.parseInt(ROOT_APP);
        Integer database1=Integer.parseInt(DATABASE1);
        Integer database2=0;
        if(!StringUtils.isEmptyOrNull(DATABASE2)){
            database2=Integer.parseInt(DATABASE2);
        }

        int max=rootApp;
        int min=database1+database2;
        if(max<min){

            //访问应用小于数据库
            max=min;
            min=rootApp;

            if(i%min<(max/2)){
                User user=this.userService.getUserById("admin");
                User user1=this.userService.getUserById("admin");
            }
        }else{

//            访问数据库小于访问应用
            if(i%max<min){
                User user=this.userService.getUserById("admin");
            }

        }

        i=testMathRandom1000();

        if(i%SLEEP_RATE==0){
            sleep(i*10);
        }

        if(i% ERROR_RATE ==0){
            throw new NullPointerException();
        }
        return "User";
    }

    @RequestMapping({"/base.do"})
    public String base(HttpServletRequest request, Model model) throws Exception {

        int i=testMathRandom10000();

        new Test1();
        Integer rootApp=Integer.parseInt(ROOT_APP);
        Integer database1=Integer.parseInt(DATABASE1);
        Integer database2=0;
        if(!StringUtils.isEmptyOrNull(DATABASE2)){
            database2=Integer.parseInt(DATABASE2);
        }

        int max=rootApp;
        int min=database1+database2;
        if(max<min){

            //访问应用小于数据库
            max=min;
            min=rootApp;

            if(i%min<(max/2)){
                User user=this.userService.getUserById("admin");
                User user1=this.userService.getUserById("admin");
            }
        }else{

//            访问数据库小于访问应用
            if(i%max<min){
                User user=this.userService.getUserById("admin");
            }

        }


        if(i%SLEEP_RATE==0){
            sleep(i*10);
        }

        if(i% ERROR_RATE ==0){
            throw new NullPointerException();
        }
        return "User";
    }

    @RequestMapping({"/baseAdd.do"})
    public String baseAdd(HttpServletRequest request, Model model) throws Exception {

        int i=testMathRandom10000();

        new Test1();
        Integer rootApp=Integer.parseInt(ROOT_APP);
        Integer database1=Integer.parseInt(DATABASE1);
        Integer database2=0;
        if(!StringUtils.isEmptyOrNull(DATABASE2)){
            database2=Integer.parseInt(DATABASE2);
        }

        int max=rootApp;
        int min=database1+database2;
        if(max<min){

            //访问应用小于数据库
            max=min;
            min=rootApp;

            if(i%min<(max/2)){
                User user=this.userService.getUserById("admin");
                User user1=this.userService.getUserById("admin");
            }
        }else{

//            访问数据库小于访问应用
            if(i%max<min){
                User user=this.userService.getUserById("admin");
            }

        }


        if(i%SLEEP_RATE==0){
            sleep(i*10);
        }

        if(i% ERROR_RATE ==0){
            throw new NullPointerException();
        }
        return "User";
    }

    @RequestMapping({"/baseDelete.do"})
    public String baseDelete(HttpServletRequest request, Model model) throws Exception {

        int i=testMathRandom10000();

        new Test1();
        Integer rootApp=Integer.parseInt(ROOT_APP);
        Integer database1=Integer.parseInt(DATABASE1);
        Integer database2=0;
        if(!StringUtils.isEmptyOrNull(DATABASE2)){
            database2=Integer.parseInt(DATABASE2);
        }

        int max=rootApp;
        int min=database1+database2;
        if(max<min){

            //访问应用小于数据库
            max=min;
            min=rootApp;

            if(i%min<(max/2)){
                User user=this.userService.getUserById("admin");
                User user1=this.userService.getUserById("admin");
            }
        }else{

//            访问数据库小于访问应用
            if(i%max<min){
                User user=this.userService.getUserById("admin");
            }

        }


        if(i%SLEEP_RATE==0){
            sleep(i*10);
        }

        if(i% ERROR_RATE ==0){
            throw new NullPointerException();
        }
        return "User";
    }

    @RequestMapping({"/baseUpdate.do"})
    public String baseUpdate(HttpServletRequest request, Model model) throws Exception {

        int i=testMathRandom10000();

        new Test1();
        Integer rootApp=Integer.parseInt(ROOT_APP);
        Integer database1=Integer.parseInt(DATABASE1);
        Integer database2=0;
        if(!StringUtils.isEmptyOrNull(DATABASE2)){
            database2=Integer.parseInt(DATABASE2);
        }

        int max=rootApp;
        int min=database1+database2;
        if(max<min){

            //访问应用小于数据库
            max=min;
            min=rootApp;

            if(i%min<(max/2)){
                User user=this.userService.getUserById("admin");
                User user1=this.userService.getUserById("admin");
            }
        }else{

//            访问数据库小于访问应用
            if(i%max<min){
                User user=this.userService.getUserById("admin");
            }

        }


        if(i%SLEEP_RATE==0){
            sleep(i*10);
        }

        if(i% ERROR_RATE ==0){
            throw new NullPointerException();
        }
        return "User";
    }

    @RequestMapping({"/baseQuery.do"})
    public String baseQuery(HttpServletRequest request, Model model) throws Exception {

        int i=testMathRandom10000();

        new Test1();
        Integer rootApp=Integer.parseInt(ROOT_APP);
        Integer database1=Integer.parseInt(DATABASE1);
        Integer database2=0;
        if(!StringUtils.isEmptyOrNull(DATABASE2)){
            database2=Integer.parseInt(DATABASE2);
        }

        int max=rootApp;
        int min=database1+database2;
        if(max<min){

            //访问应用小于数据库
            max=min;
            min=rootApp;

            if(i%min<(max/2)){
                User user=this.userService.getUserById("admin");
                User user1=this.userService.getUserById("admin");
            }
        }else{

//            访问数据库小于访问应用
            if(i%max<min){
                User user=this.userService.getUserById("admin");
            }

        }


        if(i%SLEEP_RATE==0){
            sleep(i*10);
        }

        if(i% ERROR_RATE ==0){
            throw new NullPointerException();
        }
        return "User";
    }

    @RequestMapping({"/bellamy.do"})
    public String bellamy(HttpServletRequest request,
                          HttpServletResponse response,
                          Model model) throws Exception {
        new Test1();
        logger.info("fdfdfdfdfdfdfs");
        logger.info(MDC.get("PtxId"));
        String url=request.getParameter("url");
        logger.info(url);
//        executeGet(url);
        int topApp=Integer.parseInt(ROOT_APP);
        int app1=Integer.parseInt(APP1);
        int app2=Integer.parseInt(APP2);
        int app3=Integer.parseInt(APP3);
        int app4=Integer.parseInt(APP4);

        int i=testMathRandom10000();

        int j=i%topApp;

        if(j<app1){
            logger.info(toAppUrl1);
            executeGet(toAppUrl1);
        }

        if(j<app2){
            logger.info(appUrl2+testUrl(i%4));
            executeGet(appUrl2+testUrl(i%4));
        }

        if(j<app3){
            logger.info(appUrl3+testUrl(i%4));
            executeGet(appUrl3+testUrl(i%4));
        }

        if(j<app4){
            logger.info(toAppUrl4);
            executeGet(toAppUrl4);
        }

        throw new NullPointerException();

//        this.userService.getUserById("admin");
//        int i=testMathRandom();
////        this.userService.selectSlowSql("admin");
//        if(i% CERT_RATE ==0){
//            throw new NullPointerException();
//        }
//        return "User";
    }

    @RequestMapping({"/toThunders.do"})
    public String toThunders(HttpServletRequest request,
                             HttpServletResponse response,
                             Model model) throws Exception {
//        new Test1();
//        logger.info("fdfdfdfdfdfdfs");
//        logger.info(MDC.get("PtxId"));
//        String url=request.getParameter("url");
//        logger.info(url);
//        executeGet(url);
//        this.userService.getUserById("admin");
//        int i=testMathRandom();
////        this.userService.selectSlowSql("admin");
//        if(i% CERT_RATE ==0){
//            throw new NullPointerException();
//        }
        return "User";
    }

    @RequestMapping({"/thunders.do"})
    public String thunders(HttpServletRequest request, Model model) throws Exception {

        int i=testMathRandom10000();

        new Test1();
        Integer rootApp=Integer.parseInt(ROOT_APP);
        Integer database1=Integer.parseInt(DATABASE1);
        Integer database2=0;
        if(!StringUtils.isEmptyOrNull(DATABASE2)){
            database2=Integer.parseInt(DATABASE2);
        }

        int max=rootApp;
        int min=database1+database2;
        if(max<min){

            //访问应用小于数据库
            max=min;
            min=rootApp;

            if(i%min<(max/2)){
                User user=this.userService.getUserById("admin");
                User user1=this.userService.getUserById("admin");
            }
        }else{

//            访问数据库小于访问应用
            if(i%max<min){
                User user=this.userService.getUserById("admin");
            }

        }

        i=testMathRandom1000();

        if(i%SLEEP_RATE==0){
            sleep(i*10);
        }

        if(i% ERROR_RATE ==0){
            throw new NullPointerException();
        }
        return "User";
    }

    @RequestMapping({"/thundersAdd.do"})
    public String thundersAdd(HttpServletRequest request, Model model) throws Exception {

        int i=testMathRandom10000();

        new Test1();
        Integer rootApp=Integer.parseInt(ROOT_APP);
        Integer database1=Integer.parseInt(DATABASE1);
        Integer database2=0;
        if(!StringUtils.isEmptyOrNull(DATABASE2)){
            database2=Integer.parseInt(DATABASE2);
        }

        int max=rootApp;
        int min=database1+database2;
        if(max<min){

            //访问应用小于数据库
            max=min;
            min=rootApp;

            if(i%min<(max/2)){
                User user=this.userService.getUserById("admin");
                User user1=this.userService.getUserById("admin");
            }
        }else{

//            访问数据库小于访问应用
            if(i%max<min){
                User user=this.userService.getUserById("admin");
            }

        }

        i=testMathRandom1000();

        if(i%SLEEP_RATE==0){
            sleep(i*10);
        }

        if(i% ERROR_RATE ==0){
            throw new NullPointerException();
        }
        return "User";
    }

    @RequestMapping({"/thundersDelete.do"})
    public String thundersDelete(HttpServletRequest request, Model model) throws Exception {

        int i=testMathRandom10000();

        new Test1();
        Integer rootApp=Integer.parseInt(ROOT_APP);
        Integer database1=Integer.parseInt(DATABASE1);
        Integer database2=0;
        if(!StringUtils.isEmptyOrNull(DATABASE2)){
            database2=Integer.parseInt(DATABASE2);
        }

        int max=rootApp;
        int min=database1+database2;
        if(max<min){

            //访问应用小于数据库
            max=min;
            min=rootApp;

            if(i%min<(max/2)){
                User user=this.userService.getUserById("admin");
                User user1=this.userService.getUserById("admin");
            }
        }else{

//            访问数据库小于访问应用
            if(i%max<min){
                User user=this.userService.getUserById("admin");
            }

        }

        i=testMathRandom1000();

        if(i%SLEEP_RATE==0){
            sleep(i*10);
        }

        if(i% ERROR_RATE ==0){
            throw new NullPointerException();
        }
        return "User";
    }

    @RequestMapping({"/thundersUpdate.do"})
    public String thundersUpdate(HttpServletRequest request, Model model) throws Exception {

        int i=testMathRandom10000();

        new Test1();
        Integer rootApp=Integer.parseInt(ROOT_APP);
        Integer database1=Integer.parseInt(DATABASE1);
        Integer database2=0;
        if(!StringUtils.isEmptyOrNull(DATABASE2)){
            database2=Integer.parseInt(DATABASE2);
        }

        int max=rootApp;
        int min=database1+database2;
        if(max<min){

            //访问应用小于数据库
            max=min;
            min=rootApp;

            if(i%min<(max/2)){
                User user=this.userService.getUserById("admin");
                User user1=this.userService.getUserById("admin");
            }
        }else{

//            访问数据库小于访问应用
            if(i%max<min){
                User user=this.userService.getUserById("admin");
            }

        }

        i=testMathRandom1000();

        if(i%SLEEP_RATE==0){
            sleep(i*10);
        }

        if(i% ERROR_RATE ==0){
            throw new NullPointerException();
        }
        return "User";
    }

    @RequestMapping({"/thundersQuery.do"})
    public String thundersQuery(HttpServletRequest request, Model model) throws Exception {

        int i=testMathRandom10000();

        new Test1();
        Integer rootApp=Integer.parseInt(ROOT_APP);
        Integer database1=Integer.parseInt(DATABASE1);
        Integer database2=0;
        if(!StringUtils.isEmptyOrNull(DATABASE2)){
            database2=Integer.parseInt(DATABASE2);
        }

        int max=rootApp;
        int min=database1+database2;
        if(max<min){

            //访问应用小于数据库
            max=min;
            min=rootApp;

            if(i%min<(max/2)){
                User user=this.userService.getUserById("admin");
                User user1=this.userService.getUserById("admin");
            }
        }else{

//            访问数据库小于访问应用
            if(i%max<min){
                User user=this.userService.getUserById("admin");
            }

        }

        i=testMathRandom1000();

        if(i%SLEEP_RATE==0){
            sleep(i*10);
        }

        if(i% ERROR_RATE ==0){
            throw new NullPointerException();
        }
        return "User";
    }

    @RequestMapping({"/toNuggets.do"})
    public String toNuggets(HttpServletRequest request,
                            HttpServletResponse response,
                            Model model) throws Exception {

        int i=testMathRandom10000();

        int app3=Integer.parseInt(APP3);
        int app4=Integer.parseInt(APP4);

        if(app3>app4){
            if(i%app4>(app3/2)){
//                executeGet(appUrl1+testUrl(i%4));
//                executeGet(appUrl1+testUrl(i%4));
                User user=this.userService.getUserById("admin");
                User user1=this.userService.getUserById("admin");
            }
        }else{
            if(i%app4>app3){
//                executeGet(appUrl1+testUrl(i%4));
                User user=this.userService.getUserById("admin");
            }
        }

        if(i%ERROR_RATE==0){
            throw new NullPointerException();
        }
//        new Test1();
//        logger.info("fdfdfdfdfdfdfs");
//        logger.info(MDC.get("PtxId"));
//        String url=request.getParameter("url");
//        logger.info(url);
//        executeGet(url);
//        this.userService.getUserById("admin");
//        int i=testMathRandom();
////        this.userService.selectSlowSql("admin");
//        if(i% CERT_RATE ==0){
//            throw new NullPointerException();
//        }
        return "User";
    }

    @RequestMapping({"/nuggetsAdd.do"})
    public String nuggetsAdd(HttpServletRequest request, Model model) throws Exception {

        int i=testMathRandom10000();

        new Test1();
        Integer rootApp=Integer.parseInt(ROOT_APP);
        Integer database1=Integer.parseInt(DATABASE1);
        Integer database2=0;
        if(!StringUtils.isEmptyOrNull(DATABASE2)){
            database2=Integer.parseInt(DATABASE2);
        }

        int max=rootApp;
        int min=database1+database2;
        if(max<min){

            //访问应用小于数据库
            max=min;
            min=rootApp;

            if(i%min<(max/2)){
                User user=this.userService.getUserById("admin");
                User user1=this.userService.getUserById("admin");
            }
        }else{

//            访问数据库小于访问应用
            if(i%max<min){
                User user=this.userService.getUserById("admin");
            }

        }

        i=testMathRandom1000();

        if(i%SLEEP_RATE==0){
            sleep(i*10);
        }

        if(i% ERROR_RATE ==0){
            throw new NullPointerException();
        }
        return "User";
    }

    @RequestMapping({"/nuggetsDelete.do"})
    public String nuggetsDelete(HttpServletRequest request, Model model) throws Exception {

        int i=testMathRandom10000();

        new Test1();
        Integer rootApp=Integer.parseInt(ROOT_APP);
        Integer database1=Integer.parseInt(DATABASE1);
        Integer database2=0;
        if(!StringUtils.isEmptyOrNull(DATABASE2)){
            database2=Integer.parseInt(DATABASE2);
        }

        int max=rootApp;
        int min=database1+database2;
        if(max<min){

            //访问应用小于数据库
            max=min;
            min=rootApp;

            if(i%min<(max/2)){
                User user=this.userService.getUserById("admin");
                User user1=this.userService.getUserById("admin");
            }
        }else{

//            访问数据库小于访问应用
            if(i%max<min){
                User user=this.userService.getUserById("admin");
            }

        }

        i=testMathRandom1000();

        if(i%SLEEP_RATE==0){
            sleep(i*10);
        }

        if(i% ERROR_RATE ==0){
            throw new NullPointerException();
        }
        return "User";
    }

    @RequestMapping({"/nuggetsUpdate.do"})
    public String nuggetsUpdate(HttpServletRequest request, Model model) throws Exception {

        int i=testMathRandom10000();

        new Test1();
        Integer rootApp=Integer.parseInt(ROOT_APP);
        Integer database1=Integer.parseInt(DATABASE1);
        Integer database2=0;
        if(!StringUtils.isEmptyOrNull(DATABASE2)){
            database2=Integer.parseInt(DATABASE2);
        }

        int max=rootApp;
        int min=database1+database2;
        if(max<min){

            //访问应用小于数据库
            max=min;
            min=rootApp;

            if(i%min<(max/2)){
                User user=this.userService.getUserById("admin");
                User user1=this.userService.getUserById("admin");
            }
        }else{

//            访问数据库小于访问应用
            if(i%max<min){
                User user=this.userService.getUserById("admin");
            }

        }

        i=testMathRandom1000();

        if(i%SLEEP_RATE==0){
            sleep(i*10);
        }

        if(i% ERROR_RATE ==0){
            throw new NullPointerException();
        }
        return "User";
    }

    @RequestMapping({"/nuggetsQuery.do"})
    public String nuggetsQuery(HttpServletRequest request, Model model) throws Exception {

        int i=testMathRandom10000();

        new Test1();
        Integer rootApp=Integer.parseInt(ROOT_APP);
        Integer database1=Integer.parseInt(DATABASE1);
        Integer database2=0;
        if(!StringUtils.isEmptyOrNull(DATABASE2)){
            database2=Integer.parseInt(DATABASE2);
        }

        int max=rootApp;
        int min=database1+database2;
        if(max<min){

            //访问应用小于数据库
            max=min;
            min=rootApp;

            if(i%min<(max/2)){
                User user=this.userService.getUserById("admin");
                User user1=this.userService.getUserById("admin");
            }
        }else{

//            访问数据库小于访问应用
            if(i%max<min){
                User user=this.userService.getUserById("admin");
            }

        }

        i=testMathRandom1000();

        if(i%SLEEP_RATE==0){
            sleep(i*10);
        }

        if(i% ERROR_RATE ==0){
            throw new NullPointerException();
        }
        return "User";
    }

}
